/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cardarus.operatingsystem.domain;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * This class represents the Customer's reward account.
 * It maintains Customer's reward points and balance.
 *
 * @author Javier
 */
@Entity
public class RewardMembership implements Serializable {

    /**
     * The list of points movements in this reward account.
     */
    @OneToMany(mappedBy = "account")
    private List<PointsTransaction> pointsMovements;

    /**
     * The id of this reward account.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

    /**
     * The Customer associated with this reminder.
     */
    @OneToOne(mappedBy = "pointsAccount")
    private Customer customer;

    /**
     * The current balance of this reward account.
     */
    private int balance;

    /**
     * @return the id of this reward account.
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) getId();
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RewardMembership)) {
            return false;
        }
        RewardMembership other = (RewardMembership) object;
        if (this.getId() != other.getId()) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.cardarus.operatingsystem.domain.PointsAccount[id=" + getId() + "]";
    }

    /**
     * @return the customer
     */
    public Customer getCustomer() {
        return customer;
    }

    /**
     * @param customer the customer to set
     */
    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    /**
     * @return the balance
     */
    public int getBalance() {
        return balance;
    }

    /**
     * @param balance the balance to set
     */
    public void setBalance(int balance) {
        this.balance = balance;
    }

    /**
     * @return the list of points transaction
     */
    public List<PointsTransaction> getPointsMovements() {
        return pointsMovements;
    }

    /**
     * @param pointsMovements the list of points transaction to set
     */
    public void setPointsMovements(List<PointsTransaction> pointsMovements) {
        this.pointsMovements = pointsMovements;
    }
}
